<?php

/**
 * Payments filter form base class.
 *
 * @package    dashboard
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BasePaymentsFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'payment_type'       => new sfWidgetFormChoice(array('choices' => array('' => '', 'incoming' => 'incoming', 'outgoing' => 'outgoing'))),
      'payment_amount'     => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'payment_date'       => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'payment_ext_data'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'payment_method'     => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'payment_method_num' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'payment_approved'   => new sfWidgetFormChoice(array('choices' => array('' => '', 'yes' => 'yes', 'no' => 'no'))),
      'invoice_id'         => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'invoice_group'      => new sfWidgetFormFilterInput(array('with_empty' => false)),
    ));

    $this->setValidators(array(
      'payment_type'       => new sfValidatorChoice(array('required' => false, 'choices' => array('incoming' => 'incoming', 'outgoing' => 'outgoing'))),
      'payment_amount'     => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'payment_date'       => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'payment_ext_data'   => new sfValidatorPass(array('required' => false)),
      'payment_method'     => new sfValidatorPass(array('required' => false)),
      'payment_method_num' => new sfValidatorPass(array('required' => false)),
      'payment_approved'   => new sfValidatorChoice(array('required' => false, 'choices' => array('yes' => 'yes', 'no' => 'no'))),
      'invoice_id'         => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'invoice_group'      => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
    ));

    $this->widgetSchema->setNameFormat('payments_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Payments';
  }

  public function getFields()
  {
    return array(
      'payment_id'         => 'Number',
      'payment_type'       => 'Enum',
      'payment_amount'     => 'Number',
      'payment_date'       => 'Date',
      'payment_ext_data'   => 'Text',
      'payment_method'     => 'Text',
      'payment_method_num' => 'Text',
      'payment_approved'   => 'Enum',
      'invoice_id'         => 'Number',
      'invoice_group'      => 'Number',
    );
  }
}
